from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep

driver =webdriver.Edge()
sleep(1)
driver.get('https://www.ctrip.com/')
sleep(1)
# 浏览器窗口放大事件
driver.maximize_window()
sleep(2)
# 向下滚动
driver.execute_script("window.scrollTo(0,500)")
sleep(2)
# 浏览器刷新事件
driver.refresh()
sleep(2)
# 点击登录
driver.find_element(By.CLASS_NAME,'tl_nfes_home_header_login_not_frb4a').click()
sleep(2)
# 勾选协议
driver.find_element(By.CSS_SELECTOR,'#bbz_accounts_pc_lg_box > div > div > div.lg_loginbox.lg_ercode > div:nth-child(5) > div > div.checkbox-agreement > label').click()
sleep(1)
# 点击qq登录
driver.find_element(By.CLASS_NAME,'icon-qq').click()
sleep(2)
# 窗口切换
driver.switch_to.window(driver.window_handles[-1])
sleep(3)
# 进入frame框架
f = driver.find_element(By.ID,'ptlogin_iframe')
driver.switch_to.frame(f)
sleep(2)
# 浏览器退出事件
driver.quit()
sleep(1)

